package com.jk.vehicle.mini.controller.base;

import com.jk.vehicle.mini.entity.MileageStatisticsWeek;
import com.jk.vehicle.mini.service.CorpService;
import com.jk.vehicle.mini.service.MileageStatisticsWeekService;
import com.jk.vehicle.mini.util.SequenceUtils;
import com.jk.vehicle.core.controller.BaseController;
import com.jk.vehicle.core.entity.ResponseEntity;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * This is Description for MileageStatisticsWeekController
 *
 * @author zhangdongdong
 * @date 2021/02/09
 */
@Api(value = "里程周统计接口", tags = "里程周统计接口")
@RestController
@RequestMapping("/mileage/statistics/week")
public class MileageStatisticsWeekController extends BaseController {

	/**
	 * MileageStatisticsWeekService服务
	 */
    @Resource
    private MileageStatisticsWeekService mileageStatisticsWeekService;

    @Resource
    private CorpService corpService;

	/**
	 * 分页查询mileageStatisticsWeek
	 * @param page 页码
	 * @param size 单页查询条数
     * @param paramMap 查询条件参数
	 * @return 查询结果
	 */
    @ApiOperation("分页查询周里程统计数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "paramMap", value = "高级检索条件"),
            @ApiImplicitParam(name = "corpId", value = "厂家ID")
    })
    @GetMapping("/list_page")
    public ResponseEntity listPage(@RequestParam(defaultValue = "0") Integer page,
            @RequestParam(defaultValue = "0") Integer size, @RequestParam Map<String, Object> paramMap, Long corpId) {
        if (corpId == null || corpId.longValue() == 0) {
            return failResult("厂家id不能为空！");
        }
        if (corpId == -1) {
            return failResult("厂家id不能等于-1！");
        }
        String dsName = corpService.selectDsNameById(corpId);
        PageHelper.startPage(page, size);
        List<MileageStatisticsWeek> list = mileageStatisticsWeekService.queryByParams(paramMap, dsName);
        PageInfo pageInfo = new PageInfo(list);
        return successResult(pageInfo);
    }
}
